import 'dart:io';

import 'package:ac/common/ac_upload_util.dart';
import 'package:ac/data/ac_user_manager.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../route/ac_route_pages.dart';
import 'ac_main_logic.dart';

class AcMainPage extends StatelessWidget {
  final logic = Get.find<AcMainLogic>();
  final state = Get.find<AcMainLogic>().state;

  AcMainPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          // AcUploadUtil.uploadFile(File("path"));
          Get.toNamed(AcRouteNames.publish);
        },
        elevation: 0,
        backgroundColor: Colors.transparent,
        focusColor: Colors.transparent,
        hoverColor: Colors.transparent,
        splashColor: Colors.transparent,
        focusElevation: 0,
        highlightElevation: 0,
        child: Image.asset(
          "images/home/flot_btn.png",
          width: 52.w,
          height: 52.w,
        ),
      ),
      body: Container(
        width: 375.w,
        decoration: const BoxDecoration(
          image: DecorationImage(
            image: AssetImage("images/bg_main.png"),
            fit: BoxFit.fill,
          ),
        ),
        padding: EdgeInsets.symmetric(horizontal: 32.w),
        child: ListView(
          padding: EdgeInsets.zero,
          children: [
            SizedBox(
              height: 120.h,
            ),
            Row(
              children: [
                Image.asset(
                  "images/main_top.png",
                  width: 212.w,
                  height: 86.h,
                ),
              ],
            ),
            SizedBox(height: 34.h),
            _item(1, "Mount Etna", "The largest active volcano in Europe"),
            SizedBox(height: 41.h),
            _item(2, "Kilauea Volcano",
                "Located in Hawaii, it is the most \nactive volcano in the world"),
            SizedBox(height: 34.h),
            _item(3, "Bromo", "Indonesia's most famous volcano"),
          ],
        ),
      ),
    );
  }

  Widget _item(int index, String title, String subTitle) {
    return GestureDetector(
      onTap: () {
        Get.toNamed(AcRouteNames.postList,arguments: index);
      },
      child: Container(
        width: 313.w,
        height: 123.h,
        decoration: BoxDecoration(
          image: DecorationImage(
            image: AssetImage("images/home/item_bg_$index.png"),
            fit: BoxFit.fill,
          ),
        ),
        child: Stack(
          clipBehavior: Clip.none,
          children: [
            Positioned(
              left: 30.w,
              top: -26.h,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Image.asset(
                    "images/home/item_icon_$index.png",
                    width: 74.w,
                    height: 74.w,
                  ),
                  SizedBox(height: 11.h),
                  Row(
                    children: [
                      Text(
                        title,
                        style: TextStyle(
                          fontSize: 16.sp,
                          color: Colors.white,
                          fontWeight: FontWeight.w500,
                        ),
                      ),
                      SizedBox(width: 8.w),
                      Image.asset(
                        "images/home/item_member_$index.png",
                        height: 22.w,
                      ),
                    ],
                  ),
                  SizedBox(height: 7.h),
                  Text(
                    subTitle,
                    style: TextStyle(
                      fontSize: 11.sp,
                      color: Colors.white.withOpacity(0.6),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
